package com.metalgun.sock;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;


public class Transfere {
	private String Server;
	private int port;
	
	
	public Transfere(String Server, int port){
		this.Server = Server;
		this.port = port;
	}
	
	public void Envoyer(String file){
		try {
			Socket s = new Socket(this.Server, this.port);
			InputStream in = new FileInputStream(file);
			OutputStream out = s.getOutputStream();
			byte[] buffer = new byte[256];
			while (in.read(buffer) != -1) {
				out.write(buffer);
			}
			s.close();
			System.out.println("Envoyer!");
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
	}

}
